// const { param } = require("jquery");

// pages/detail/detail.js
const APP = getApp();
Page({
  /**
   * 页面的初始数据
   */
  data: {
    detail:{},
        vModelValue: 1,
				TypeIndex: 0,
				TypeIndex2: 0,
				TypeIndex3: 0,
				TypeIndex4: 0,
				imageWidth: 0,
				imageHeight: 0,
				TabCur: 1,
				priceNum: 1680.00,
				num: 5,
				sales: 163,
				showModelPop: false,
				changtuImg: 'https://img.picgo.net/2024/05/06/changtu225e40323399f98be.jpeg',
				changtuImg2: 'https://img.picgo.net/2024/05/06/changtu1a029cb75c6cb5a60.jpeg',
				info: [{
					url: 'https://shop.rongyiht.com/static/images/detail/iphone15.png',
				}, {
					url: 'https://shop.rongyiht.com/static/images/detail/iphone15.png',
				}, {
					url: 'https://shop.rongyiht.com/static/images/detail/iphone15.png',
				}],
				current: 0,
				mode: 'dot',
				dotsStyles: [{
					backgroundColor: 'rgba(0, 0, 0, .3)',
					border: '1px rgba(0, 0, 0, .3) solid',
					color: '#fff',
					selectedBackgroundColor: '#3ED5D0',
					selectedBorder: '1px rgba(0, 0, 0, .9) solid'
				}, ],
				functionBoxList: [
          {
          title: '分期产品',
          value:1
        },{
          title: '以租代购',
          value:2
				}
      ],
				functionBoxList2: [{
            color: '粉色',
            value:1
					},
					{
            color: '黑色',
            value:2
					},
					{
            color: '黄色',
            value:3
					},
					{
            color: '蓝色',
            value:4
					},
					{
            color: '绿色',
            value:5
					},
        ],
        param:{
          package:1,
          color:1,
          period:12,
          num:1,
          version:1,
          server:1,
        },
        showPopupBox:false,
				functionBoxList3: [{
            color: '12期',
            value:12
					}
				],
				functionBoxList4: [{
          title: '512G',
          value:1
				}],
				functionBoxList5: [{
          title: '碎屏保障￥599',
          value:1
				}],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    let id = options.id;
    let that = this;
    APP.http('post','/project_detail',{project_id:id},function(res){
      if(res.code==1){
        that.setData({
          detail:res.data.project
        })
      }else{
        wx.showLoading({
          title: '拼命加载中',
        })
      }
    })
  },
  toMain(){
    APP.jump('../main/main');
  },
  goToItem(e){
    var value = e.currentTarget.dataset.id;
    var field = e.currentTarget.dataset.field;
    var k = "param."+field+"";
    this.setData({
      [k] : value
    })

  },
  tabSelect(e) {
    this.setData({
      TabCur : e.currentTarget.dataset.id
    });
  },
  gotoPay(e){
    // uni.navigateTo({
    //   url: "/pages/classify/confirm-order"
    // })

    let id = e.currentTarget.dataset.id;
    
    let str = "&package="+this.data.param.package+"&color="+this.data.param.color+"&period="+this.data.param.period+"&version="+this.data.param.version+"&server="+this.data.param.server
    APP.jump('../confirm/confirm?id='+id+str); 
  },
  showModel() {
    var login_status = getApp().globalData.login_status;
    if(!login_status){
      APP.to_login_();return;
    }
    this.setData({
      showPopupBox:true
    })
    // console.log(this.$refs.popup)
    // this.$refs.popup.open('bottom')
  },
  closeModel(){
    this.setData({
      showPopupBox:false
    })
  },
  goshowChange(item, index) {
    this.TypeIndex = index;

  },
  goshowChange2(item, index) {
    this.TypeIndex2 = index;
  },
  goshowChange3(item, index) {
    this.TypeIndex3 = index;
  },
  goshowChange4(item, index) {
    this.TypeIndex4 = index;
  },
  // gotoPay(){
  //   uni.navigateTo({
  //     url: "/pages/classify/confirm-order"
  //   })
  // },
  
  
/**
 * 去申请下单
 */
  to_apply(e){
    let id = e.currentTarget.dataset.id;
    let name = e.currentTarget.dataset.name;
    let price = e.currentTarget.dataset.price;
    APP.jump('../apply/apply?id='+id+'&name='+name+'&price='+price); 
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})